﻿// Study0706.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。
// 第七章 继承 虚基类

#include <iostream>
using namespace std;
class Base0
{
public:
	Base0(int a) {
		cout << "a=" << var0<<endl;
	}
	int var0 = 0;
	void func()
	{
		cout << "调用Base0类的function。" << endl;
	}
};
class Base1:virtual public Base0
{
public:
	Base1(int a): Base0(a)
	{
		cout << "a=" << var0 << endl;
	}

	int var1 = 1;
	void func()
	{
		cout << "调用Base1类的function。" << endl;
	}
};
class Base2:virtual public Base0
{
public:
	Base2(int a) : Base0(a)
	{
		cout << "a=" << var0 << endl;
	}

	int var2 = 2;
	void func()
	{
		cout << "调用Base2类的function。" << endl;
	}
};

class Derived :public Base1, public Base2
{
public:
	Derived(int a) : Base0(a), Base1(a),Base2(a)
	{
		cout << "a=" << var << endl;
	}
	int var = 10;
	void func()
	{
		cout << "调用Derived类的function。" << endl;
	}

};
int main()
{
	Derived der(11);
	der.func();


	return 0;
}

